from tkinter import *
from lxg_tkinter import demos, Quitter


class Demo(Frame):
    def __init__(self, parent=None, **options):
        Frame.__init__(self, parent, **options)
        self.pack()
        Label(self, text="单选案例").pack(side=TOP)
        self.var = StringVar()
        for k in demos:
            Radiobutton(self,
                        text=k,
                        command=self.on_press,
                        variable=self.var,
                        value=k).pack(anchor=NW)
        self.var.set(k)  #选中最后一个
        Button(self, text='状态', command=self.report).pack(fill=X)
        Quitter(self).pack(fill=X)

    def on_press(self):
        pick = self.var.get()
        print("您按下的：", pick)
        print("结果：", demos[pick]())

    def report(self):
        print(self.var.get())


if __name__ == '__main__':
    Demo().mainloop()